<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 
            找出所有的递增子集，所以还是用回溯法。
            ①确定终止条件，无终止条件，只要有就推入，但是需要去重
            ②确定遍历集合范围 也是从start开始,只有当前元素大于path中的末尾元素，才推入path中
            */
            var findSubsequences = function (nums) {
                let res = []
                let start = 0
                let map = new Map()
                function backTacking(path, start) {
                    if (path.length > 1) {
                        let str = path.toString()
                        if (map.has(str)) return
                        map.set(str, 1)
                        res.push([...path])
                    }
                    for (let i = start; i < nums.length; i++) {
                        if (path.length == 0 || nums[i] >= path[path.length - 1]) {
                            path.push(nums[i])
                            backTacking(path, i + 1)
                            path.pop()
                        }
                    }
                }
                backTacking([], 0)
                return res
            }
            console.log(findSubsequences([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))
        </script>
    </body>
</html>
